<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="/css/public.css" media="all">
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">
        <table class="layui-hide" id="TableId_Bot" lay-filter="TableFilter_Bot"></table>
        <script type="text/html" id="TableBar_Bot">
            <a class="layui-btn layui-btn-normal layui-btn-xs data-count-chat" lay-event="bot_offline">下线</a>
        </script>
    </div>
</div>
<script src="/lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form', 'table'], function () {
        var $ = layui.jquery,
            form = layui.form,
            table = layui.table;
        table.render({
            elem: '#TableId_Bot',
            url: '/getAdmin_Bots',
            headers: {"token":localStorage.getItem("token")},
            cols: [[
                {field: 'id', width: 80, title: 'ID', hide: true},
                {field: 'bot', width: 110, title: 'Bot', sort: true},
                {field: 'user', width: 110, title: '用户', sort: true},
                {fixed: 'right',title: '操作', minWidth: 130, toolbar: '#TableBar_Bot', align: "center"}
            ]]
        });
        /**
         * toolbar监听事件
         */
        table.on('tool(TableFilter_Bot)', function (obj) {
            if (obj.event === 'bot_offline') {
               console.log(obj.data)
            }
        });
    });
</script>
</body>
</html>